﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using UlsStudio.DesktopApp.Properties;

namespace UlsStudio.DesktopApp
{
    /// <summary>
    /// Cached version of colours in UlsStudio.DesktopApp.Properties
    /// </summary>
    public class SettingsCache
    {
        #region Singleton

        private SettingsCache()
        {
            this.LineColourCriticalBack = Settings.Default.LineColourCriticalBack;
            this.LineColourCriticalFore = Settings.Default.LineColourCriticalFore;

            this.LineColourExceptionBack = Settings.Default.LineColourExceptionBack;
            this.LineColourExceptionFore = Settings.Default.LineColourExceptionFore;

            this.LineColourUnexpectedBack = Settings.Default.LineColourUnexpectedBack;
            this.LineColourUnexpectedFore = Settings.Default.LineColourUnexpectedFore;

            this.ColoursEnabled = Settings.Default.EnableColouring;
        }

        public static SettingsCache GetSettingsCache()
        {
            if (cache == null)
            {
                cache = new SettingsCache();
            }
            return cache;
        }

        private static SettingsCache cache = null;

        #endregion

        public bool ColoursEnabled { get; set; }
        public Color LineColourCriticalFore { get; set; }
        public Color LineColourCriticalBack { get; set; }

        public Color LineColourExceptionFore { get; set; }
        public Color LineColourExceptionBack { get; set; }

        public Color LineColourUnexpectedFore { get; set; }
        public Color LineColourUnexpectedBack { get; set; }

        public static void Refresh()
        {
            cache = null;       // Force renew
        }
    }
}
